/**
 * @file BaseFun.h
 * @author 世慷 (shikang999@126.com)
 * @brief 主要用于函数实现(激活函数等)
 * @version 0.1
 * @date 2025-10-01
 * 
 * @copyright Copyright (c) 2025
 * 
 */

#pragma once
#include <cmath>
#include <memory>
#include <vector>
#include <string>
#include "BaseNodeVar.h"

namespace Net
{

//1.
enum class FunType_E : uint16_t
{
    Nothing_E       = 0,

    W_dot_x_E       = 1, // W * x = y
    W_dot_x_add_b_E = 2, // W * x + b = y

    Add_b_E         = 6, // x + b = y
    Mul_b_E         = 7, // x * b = y

    Abs_E           = 10,
    Sqrt_E          = 11,
    Log_E           = 12,
    Exp_E           = 13,

    Sin_E           = 20,
    Cos_E           = 21,
    Tan_E           = 22,
    Cot_E           = 23,
    ArcSin_E        = 24,
    ArcCos_E        = 25,
    ArcTan_E        = 26,
    ArcCot_E        = 27,
    Sinh_E          = 28,
    Cosh_E          = 29,
    Tanh_E          = 30,
    Coth_E          = 31,
    ArcSinh_E       = 32,
    ArcCosh_E       = 33,
    ArcTanh_E       = 34,
    ArcCoth_E       = 35,
};

//2.
class NetLayer;
class BaseFun
{
public:
    BaseFun(FunType_E type, const std::string &name);
    virtual ~BaseFun();

    //获取函数类型
    FunType_E getType() const;

    //获取函数名称
    const std::string &getName() const;

    //设置ID
    void setID(uint32_t id);

    //获取ID
    uint32_t getID() const;

    //函数实现
    virtual void fun(std::shared_ptr<NetLayer> &layer) = 0;

    //导数实现
    virtual void diff(std::shared_ptr<NetLayer> &layer) = 0;

private:
    uint32_t id_;
    FunType_E type_;
    std::string name_;
    
public:
    vecBaseNodeVar_t vecVar;//变量
};

}